package ApplicationStartTest.Yarn;


import ApplicationStartTest.Bean.FlowBean;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class FlowReducer extends Reducer<Text, FlowBean, Text, FlowBean> {
    @Override
    protected void reduce(Text key, Iterable<FlowBean> values, Context context) throws IOException, InterruptedException {
        Long UpFlowSum = 0L;
        Long DownFlowSum = 0L;
        for (FlowBean flowBean : values){
            UpFlowSum += flowBean.getUpFlowNum();
            DownFlowSum += flowBean.getDownFlowNum();
        }
        context.write(key, new FlowBean(Long.parseLong(key.toString()), UpFlowSum, DownFlowSum));
    }
}
